// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]
#![no_implicit_prelude]
extern crate async_trait;
extern crate bytes;
extern crate gax;
extern crate gaxi;
extern crate gtype;
extern crate lazy_static;
extern crate location;
extern crate longrunning;
extern crate lro;
extern crate reqwest;
extern crate serde;
extern crate serde_json;
extern crate serde_with;
extern crate std;
extern crate tracing;
extern crate wkt;

mod debug;
mod deserialize;
mod serialize;

/// A rule used to express this policy.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct PolicyRule {
    /// A condition which determines whether this rule is used
    /// in the evaluation of the policy. When set, the `expression` field in
    /// the `Expr' must include from 1 to 10 subexpressions, joined by the "||"
    /// or "&&" operators. Each subexpression must be of the form
    /// "resource.matchTag('<ORG_ID>/tag_key_short_name,
    /// 'tag_value_short_name')" or "resource.matchTagId('tagKeys/key_id',
    /// 'tagValues/value_id')" where key_name and value_name are the resource
    /// names for Label Keys and Values. These names are available from the Tag
    /// Manager Service. An example expression is:
    /// "resource.matchTag('123456789/environment,
    /// 'prod')" or "resource.matchTagId('tagKeys/123',
    /// 'tagValues/456')".
    pub condition: std::option::Option<gtype::model::Expr>,

    pub kind: std::option::Option<crate::model::policy_rule::Kind>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl PolicyRule {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [condition][crate::model::PolicyRule::condition].
    pub fn set_condition<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<gtype::model::Expr>,
    {
        self.condition = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [condition][crate::model::PolicyRule::condition].
    pub fn set_or_clear_condition<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<gtype::model::Expr>,
    {
        self.condition = v.map(|x| x.into());
        self
    }

    /// Sets the value of [kind][crate::model::PolicyRule::kind].
    ///
    /// Note that all the setters affecting `kind` are mutually
    /// exclusive.
    pub fn set_kind<T: std::convert::Into<std::option::Option<crate::model::policy_rule::Kind>>>(
        mut self,
        v: T,
    ) -> Self {
        self.kind = v.into();
        self
    }

    /// The value of [kind][crate::model::PolicyRule::kind]
    /// if it holds a `Values`, `None` if the field is not set or
    /// holds a different branch.
    pub fn values(
        &self,
    ) -> std::option::Option<&std::boxed::Box<crate::model::policy_rule::StringValues>> {
        #[allow(unreachable_patterns)]
        self.kind.as_ref().and_then(|v| match v {
            crate::model::policy_rule::Kind::Values(v) => std::option::Option::Some(v),
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [kind][crate::model::PolicyRule::kind]
    /// to hold a `Values`.
    ///
    /// Note that all the setters affecting `kind` are
    /// mutually exclusive.
    pub fn set_values<
        T: std::convert::Into<std::boxed::Box<crate::model::policy_rule::StringValues>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.kind = std::option::Option::Some(crate::model::policy_rule::Kind::Values(v.into()));
        self
    }

    /// The value of [kind][crate::model::PolicyRule::kind]
    /// if it holds a `AllowAll`, `None` if the field is not set or
    /// holds a different branch.
    pub fn allow_all(&self) -> std::option::Option<&bool> {
        #[allow(unreachable_patterns)]
        self.kind.as_ref().and_then(|v| match v {
            crate::model::policy_rule::Kind::AllowAll(v) => std::option::Option::Some(v),
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [kind][crate::model::PolicyRule::kind]
    /// to hold a `AllowAll`.
    ///
    /// Note that all the setters affecting `kind` are
    /// mutually exclusive.
    pub fn set_allow_all<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.kind = std::option::Option::Some(crate::model::policy_rule::Kind::AllowAll(v.into()));
        self
    }

    /// The value of [kind][crate::model::PolicyRule::kind]
    /// if it holds a `DenyAll`, `None` if the field is not set or
    /// holds a different branch.
    pub fn deny_all(&self) -> std::option::Option<&bool> {
        #[allow(unreachable_patterns)]
        self.kind.as_ref().and_then(|v| match v {
            crate::model::policy_rule::Kind::DenyAll(v) => std::option::Option::Some(v),
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [kind][crate::model::PolicyRule::kind]
    /// to hold a `DenyAll`.
    ///
    /// Note that all the setters affecting `kind` are
    /// mutually exclusive.
    pub fn set_deny_all<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.kind = std::option::Option::Some(crate::model::policy_rule::Kind::DenyAll(v.into()));
        self
    }

    /// The value of [kind][crate::model::PolicyRule::kind]
    /// if it holds a `Enforce`, `None` if the field is not set or
    /// holds a different branch.
    pub fn enforce(&self) -> std::option::Option<&bool> {
        #[allow(unreachable_patterns)]
        self.kind.as_ref().and_then(|v| match v {
            crate::model::policy_rule::Kind::Enforce(v) => std::option::Option::Some(v),
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [kind][crate::model::PolicyRule::kind]
    /// to hold a `Enforce`.
    ///
    /// Note that all the setters affecting `kind` are
    /// mutually exclusive.
    pub fn set_enforce<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.kind = std::option::Option::Some(crate::model::policy_rule::Kind::Enforce(v.into()));
        self
    }
}

impl wkt::message::Message for PolicyRule {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.securityposture.v1.PolicyRule"
    }
}

/// Defines additional types related to [PolicyRule].
pub mod policy_rule {
    #[allow(unused_imports)]
    use super::*;

    /// A message that holds specific allowed and denied values.
    /// This message can define specific values and subtrees of the Resource
    /// Manager resource hierarchy (`Organizations`, `Folders`, `Projects`) that
    /// are allowed or denied. This is achieved by using the `under:` and
    /// optional `is:` prefixes.
    /// The `under:` prefix is used to denote resource subtree values.
    /// The `is:` prefix is used to denote specific values, and is required only
    /// if the value contains a ":". Values prefixed with "is:" are treated the
    /// same as values with no prefix.
    /// Ancestry subtrees must be in one of the following formats:
    ///
    /// - `projects/<project-id>` (for example, `projects/tokyo-rain-123`)
    /// - `folders/<folder-id>` (for example, `folders/1234`)
    /// - `organizations/<organization-id>` (for example, `organizations/1234`)
    ///
    /// The `supports_under` field of the associated `Constraint`  defines
    /// whether ancestry prefixes can be used.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct StringValues {
        /// List of values allowed at this resource.
        pub allowed_values: std::vec::Vec<std::string::String>,

        /// List of values denied at this resource.
        pub denied_values: std::vec::Vec<std::string::String>,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl StringValues {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [allowed_values][crate::model::policy_rule::StringValues::allowed_values].
        pub fn set_allowed_values<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<std::string::String>,
        {
            use std::iter::Iterator;
            self.allowed_values = v.into_iter().map(|i| i.into()).collect();
            self
        }

        /// Sets the value of [denied_values][crate::model::policy_rule::StringValues::denied_values].
        pub fn set_denied_values<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<std::string::String>,
        {
            use std::iter::Iterator;
            self.denied_values = v.into_iter().map(|i| i.into()).collect();
            self
        }
    }

    impl wkt::message::Message for StringValues {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.securityposture.v1.PolicyRule.StringValues"
        }
    }

    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum Kind {
        /// List of values to be used for this policy rule. This field can be set
        /// only in policies for list constraints.
        Values(std::boxed::Box<crate::model::policy_rule::StringValues>),
        /// Setting this to true means that all values are allowed. This field can
        /// be set only in policies for list constraints.
        AllowAll(bool),
        /// Setting this to true means that all values are denied. This field can
        /// be set only in policies for list constraints.
        DenyAll(bool),
        /// If `true`, then the policy is enforced. If `false`, then any
        /// configuration is acceptable.
        /// This field can be set only in policies for boolean constraints.
        Enforce(bool),
    }
}

/// A custom constraint defined by customers which can *only* be applied to the
/// given resource types and organization.
///
/// By creating a custom constraint, customers can apply policies of this
/// custom constraint. *Creating a custom constraint itself does NOT apply any
/// policy enforcement*.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CustomConstraint {
    /// Immutable. Name of the constraint. This is unique within the organization.
    /// Format of the name should be
    ///
    ///
    /// `organizations/{organization_id}/customConstraints/{custom_constraint_id}`
    ///
    /// Example: `organizations/123/customConstraints/custom.createOnlyE2TypeVms`
    ///
    /// The max length is 70 characters and the minimum length is 1. Note that the
    /// prefix `organizations/{organization_id}/customConstraints/` is not counted.
    pub name: std::string::String,

    /// Immutable. The resource instance type on which this policy applies. Format
    /// will be of the form : `<canonical service name>/<type>` Example:
    ///
    /// - `compute.googleapis.com/Instance`.
    pub resource_types: std::vec::Vec<std::string::String>,

    /// All the operations being applied for this constraint.
    pub method_types: std::vec::Vec<crate::model::custom_constraint::MethodType>,

    /// Org policy condition/expression. For example:
    /// `resource.instanceName.matches("[production|test]_.*_(\d)+")` or,
    /// `resource.management.auto_upgrade == true`
    ///
    /// The max length of the condition is 1000 characters.
    pub condition: std::string::String,

    /// Allow or deny type.
    pub action_type: crate::model::custom_constraint::ActionType,

    /// One line display name for the UI.
    /// The max length of the display_name is 200 characters.
    pub display_name: std::string::String,

    /// Detailed information about this custom policy constraint.
    /// The max length of the description is 2000 characters.
    pub description: std::string::String,

    /// Output only. The last time this custom constraint was updated. This
    /// represents the last time that the `CreateCustomConstraint` or
    /// `UpdateCustomConstraint` RPC was called
    pub update_time: std::option::Option<wkt::Timestamp>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CustomConstraint {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::CustomConstraint::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [resource_types][crate::model::CustomConstraint::resource_types].
    pub fn set_resource_types<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.resource_types = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [method_types][crate::model::CustomConstraint::method_types].
    pub fn set_method_types<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::custom_constraint::MethodType>,
    {
        use std::iter::Iterator;
        self.method_types = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [condition][crate::model::CustomConstraint::condition].
    pub fn set_condition<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.condition = v.into();
        self
    }

    /// Sets the value of [action_type][crate::model::CustomConstraint::action_type].
    pub fn set_action_type<T: std::convert::Into<crate::model::custom_constraint::ActionType>>(
        mut self,
        v: T,
    ) -> Self {
        self.action_type = v.into();
        self
    }

    /// Sets the value of [display_name][crate::model::CustomConstraint::display_name].
    pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.display_name = v.into();
        self
    }

    /// Sets the value of [description][crate::model::CustomConstraint::description].
    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.description = v.into();
        self
    }

    /// Sets the value of [update_time][crate::model::CustomConstraint::update_time].
    pub fn set_update_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.update_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [update_time][crate::model::CustomConstraint::update_time].
    pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.update_time = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for CustomConstraint {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.securityposture.v1.CustomConstraint"
    }
}

/// Defines additional types related to [CustomConstraint].
pub mod custom_constraint {
    #[allow(unused_imports)]
    use super::*;

    /// The operation for which this constraint will be applied. To apply this
    /// constraint only when creating new VMs, the `method_types` should be
    /// `CREATE` only. To apply this constraint when creating or deleting
    /// VMs, the `method_types` should be `CREATE` and `DELETE`.
    ///
    /// `UPDATE` only custom constraints are not supported. Use `CREATE` or
    /// `CREATE, UPDATE`.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum MethodType {
        /// Unspecified. Results in an error.
        Unspecified,
        /// Constraint applied when creating the resource.
        Create,
        /// Constraint applied when updating the resource.
        Update,
        /// Constraint applied when deleting the resource.
        /// Not supported yet.
        Delete,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [MethodType::value] or
        /// [MethodType::name].
        UnknownValue(method_type::UnknownValue),
    }

    #[doc(hidden)]
    pub mod method_type {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl MethodType {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::Create => std::option::Option::Some(1),
                Self::Update => std::option::Option::Some(2),
                Self::Delete => std::option::Option::Some(3),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("METHOD_TYPE_UNSPECIFIED"),
                Self::Create => std::option::Option::Some("CREATE"),
                Self::Update => std::option::Option::Some("UPDATE"),
                Self::Delete => std::option::Option::Some("DELETE"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for MethodType {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for MethodType {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for MethodType {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::Create,
                2 => Self::Update,
                3 => Self::Delete,
                _ => Self::UnknownValue(method_type::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for MethodType {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "METHOD_TYPE_UNSPECIFIED" => Self::Unspecified,
                "CREATE" => Self::Create,
                "UPDATE" => Self::Update,
                "DELETE" => Self::Delete,
                _ => Self::UnknownValue(method_type::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for MethodType {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::Create => serializer.serialize_i32(1),
                Self::Update => serializer.serialize_i32(2),
                Self::Delete => serializer.serialize_i32(3),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for MethodType {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<MethodType>::new(
                ".google.cloud.securityposture.v1.CustomConstraint.MethodType",
            ))
        }
    }

    /// Allow or deny type.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum ActionType {
        /// Unspecified. Results in an error.
        Unspecified,
        /// Allowed action type.
        Allow,
        /// Deny action type.
        Deny,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [ActionType::value] or
        /// [ActionType::name].
        UnknownValue(action_type::UnknownValue),
    }

    #[doc(hidden)]
    pub mod action_type {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl ActionType {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::Allow => std::option::Option::Some(1),
                Self::Deny => std::option::Option::Some(2),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("ACTION_TYPE_UNSPECIFIED"),
                Self::Allow => std::option::Option::Some("ALLOW"),
                Self::Deny => std::option::Option::Some("DENY"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for ActionType {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for ActionType {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for ActionType {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::Allow,
                2 => Self::Deny,
                _ => Self::UnknownValue(action_type::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for ActionType {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "ACTION_TYPE_UNSPECIFIED" => Self::Unspecified,
                "ALLOW" => Self::Allow,
                "DENY" => Self::Deny,
                _ => Self::UnknownValue(action_type::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for ActionType {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::Allow => serializer.serialize_i32(1),
                Self::Deny => serializer.serialize_i32(2),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for ActionType {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<ActionType>::new(
                ".google.cloud.securityposture.v1.CustomConstraint.ActionType",
            ))
        }
    }
}

/// Message for Org Policy Canned Constraint.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct OrgPolicyConstraint {
    /// Required. Org Policy Canned Constraint id.
    pub canned_constraint_id: std::string::String,

    /// Required. Org PolicySpec rules.
    pub policy_rules: std::vec::Vec<crate::model::PolicyRule>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl OrgPolicyConstraint {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [canned_constraint_id][crate::model::OrgPolicyConstraint::canned_constraint_id].
    pub fn set_canned_constraint_id<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.canned_constraint_id = v.into();
        self
    }

    /// Sets the value of [policy_rules][crate::model::OrgPolicyConstraint::policy_rules].
    pub fn set_policy_rules<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::PolicyRule>,
    {
        use std::iter::Iterator;
        self.policy_rules = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for OrgPolicyConstraint {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.securityposture.v1.OrgPolicyConstraint"
    }
}

/// Message for Org Policy Custom Constraint.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct OrgPolicyConstraintCustom {
    /// Required. Org Policy Custom Constraint.
    pub custom_constraint: std::option::Option<crate::model::CustomConstraint>,

    /// Required. Org Policyspec rules.
    pub policy_rules: std::vec::Vec<crate::model::PolicyRule>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl OrgPolicyConstraintCustom {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [custom_constraint][crate::model::OrgPolicyConstraintCustom::custom_constraint].
    pub fn set_custom_constraint<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::CustomConstraint>,
    {
        self.custom_constraint = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [custom_constraint][crate::model::OrgPolicyConstraintCustom::custom_constraint].
    pub fn set_or_clear_custom_constraint<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::CustomConstraint>,
    {
        self.custom_constraint = v.map(|x| x.into());
        self
    }

    /// Sets the value of [policy_rules][crate::model::OrgPolicyConstraintCustom::policy_rules].
    pub fn set_policy_rules<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::PolicyRule>,
    {
        use std::iter::Iterator;
        self.policy_rules = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for OrgPolicyConstraintCustom {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.securityposture.v1.OrgPolicyConstraintCustom"
    }
}

/// Represents the metadata of the long-running operation.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct OperationMetadata {
    /// Output only. The time the operation was created.
    pub create_time: std::option::Option<wkt::Timestamp>,

    /// Output only. The time the operation finished running.
    pub end_time: std::option::Option<wkt::Timestamp>,

    /// Output only. Server-defined resource path for the target of the operation.
    pub target: std::string::String,

    /// Output only. Name of the verb executed by the operation.
    pub verb: std::string::String,

    /// Output only. Human-readable status of the operation, if any.
    pub status_message: std::string::String,

    /// Output only. Identifies whether the user has requested cancellation
    /// of the operation. Operations that have been cancelled successfully
    /// have [Operation.error][] value with a
    /// [google.rpc.Status.code][google.rpc.Status.code] of 1, corresponding to
    /// `Code.CANCELLED`.
    ///
    /// [google.rpc.Status.code]: rpc::model::Status::code
    pub requested_cancellation: bool,

    /// Output only. API version used to start the operation.
    pub api_version: std::string::String,

    /// Output only. This is a output only optional field which will be filled only
    /// in cases where PostureDeployments enter failure states like UPDATE_FAILED
    /// or CREATE_FAILED or DELETE_FAILED.
    pub error_message: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl OperationMetadata {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [create_time][crate::model::OperationMetadata::create_time].
    pub fn set_create_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [create_time][crate::model::OperationMetadata::create_time].
    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [end_time][crate::model::OperationMetadata::end_time].
    pub fn set_end_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.end_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [end_time][crate::model::OperationMetadata::end_time].
    pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.end_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [target][crate::model::OperationMetadata::target].
    pub fn set_target<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.target = v.into();
        self
    }

    /// Sets the value of [verb][crate::model::OperationMetadata::verb].
    pub fn set_verb<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.verb = v.into();
        self
    }

    /// Sets the value of [status_message][crate::model::OperationMetadata::status_message].
    pub fn set_status_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.status_message = v.into();
        self
    }

    /// Sets the value of [requested_cancellation][crate::model::OperationMetadata::requested_cancellation].
    pub fn set_requested_cancellation<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.requested_cancellation = v.into();
        self
    }

    /// Sets the value of [api_version][crate::model::OperationMetadata::api_version].
    pub fn set_api_version<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.api_version = v.into();
        self
    }

    /// Sets the value of [error_message][crate::model::OperationMetadata::error_message].
    pub fn set_error_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.error_message = v.into();
        self
    }
}

impl wkt::message::Message for OperationMetadata {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.securityposture.v1.OperationMetadata"
    }
}

/// Postures
/// Definition of a Posture.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Posture {
    /// Required. Identifier. The name of this Posture resource, in the format of
    /// organizations/{org_id}/locations/{location_id}/postures/{posture}.
    pub name: std::string::String,

    /// Required. State of Posture resource.
    pub state: crate::model::posture::State,

    /// Output only. Immutable. The revision ID of the posture.
    /// The format is an 8-character hexadecimal string.
    /// <https://google.aip.dev/162>
    pub revision_id: std::string::String,

    /// Output only. The timestamp that the posture was created.
    pub create_time: std::option::Option<wkt::Timestamp>,

    /// Output only. The timestamp that the posture was updated.
    pub update_time: std::option::Option<wkt::Timestamp>,

    /// Optional. User provided description of the posture.
    pub description: std::string::String,

    /// Required. List of Policy sets.
    pub policy_sets: std::vec::Vec<crate::model::PolicySet>,

    /// Optional. An opaque tag indicating the current version of the Posture, used
    /// for concurrency control. When the `Posture` is returned from either a
    /// `GetPosture` or a `ListPostures` request, this `etag` indicates the version
    /// of the current `Posture` to use when executing a read-modify-write loop.
    ///
    /// When the `Posture` is used in a `UpdatePosture` method, use the `etag`
    /// value that was returned from a `GetPosture` request as part of a
    /// read-modify-write loop for concurrency control. Not setting the `etag` in a
    /// `UpdatePosture` request will result in an unconditional write of the
    /// `Posture`.
    pub etag: std::string::String,

    /// Optional. User annotations. These attributes can only be set and used by
    /// the user, and not by Google Security Postures.
    /// .
    pub annotations: std::collections::HashMap<std::string::String, std::string::String>,

    /// Output only. Whether or not this Posture is in the process of being
    /// updated.
    pub reconciling: bool,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Posture {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::Posture::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [state][crate::model::Posture::state].
    pub fn set_state<T: std::convert::Into<crate::model::posture::State>>(mut self, v: T) -> Self {
        self.state = v.into();
        self
    }

    /// Sets the value of [revision_id][crate::model::Posture::revision_id].
    pub fn set_revision_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.revision_id = v.into();
        self
    }

    /// Sets the value of [create_time][crate::model::Posture::create_time].
    pub fn set_create_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [create_time][crate::model::Posture::create_time].
    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [update_time][crate::model::Posture::update_time].
    pub fn set_update_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.update_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [update_time][crate::model::Posture::update_time].
    pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.update_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [description][crate::model::Posture::description].
    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.description = v.into();
        self
    }

    /// Sets the value of [policy_sets][crate::model::Posture::policy_sets].
    pub fn set_policy_sets<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::PolicySet>,
    {
        use std::iter::Iterator;
        self.policy_sets = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [etag][crate::model::Posture::etag].
    pub fn set_etag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.etag = v.into();
        self
    }

    /// Sets the value of [annotations][crate::model::Posture::annotations].
    pub fn set_annotations<T, K, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = (K, V)>,
        K: std::convert::Into<std::string::String>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.annotations = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
        self
    }

    /// Sets the value of [reconciling][crate::model::Posture::reconciling].
    pub fn set_reconciling<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.reconciling = v.into();
        self
    }
}

impl wkt::message::Message for Posture {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.securityposture.v1.Posture"
    }
}

/// Defines additional types related to [Posture].
pub mod posture {
    #[allow(unused_imports)]
    use super::*;

    /// State of a Posture.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum State {
        /// Unspecified operation state.
        Unspecified,
        /// The Posture is marked deprecated when it is not in use by the user.
        Deprecated,
        /// The Posture is created successfully but is not yet ready for usage.
        Draft,
        /// The Posture state is active. Ready for use/deployments.
        Active,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [State::value] or
        /// [State::name].
        UnknownValue(state::UnknownValue),
    }

    #[doc(hidden)]
    pub mod state {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl State {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::Deprecated => std::option::Option::Some(1),
                Self::Draft => std::option::Option::Some(2),
                Self::Active => std::option::Option::Some(3),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
                Self::Deprecated => std::option::Option::Some("DEPRECATED"),
                Self::Draft => std::option::Option::Some("DRAFT"),
                Self::Active => std::option::Option::Some("ACTIVE"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for State {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for State {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for State {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::Deprecated,
                2 => Self::Draft,
                3 => Self::Active,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for State {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "STATE_UNSPECIFIED" => Self::Unspecified,
                "DEPRECATED" => Self::Deprecated,
                "DRAFT" => Self::Draft,
                "ACTIVE" => Self::Active,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for State {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::Deprecated => serializer.serialize_i32(1),
                Self::Draft => serializer.serialize_i32(2),
                Self::Active => serializer.serialize_i32(3),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for State {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
                ".google.cloud.securityposture.v1.Posture.State",
            ))
        }
    }
}

/// PolicySet representation.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct PolicySet {
    /// Required. ID of the Policy set.
    pub policy_set_id: std::string::String,

    /// Optional. Description of the Policy set.
    pub description: std::string::String,

    /// Required. List of policies.
    pub policies: std::vec::Vec<crate::model::Policy>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl PolicySet {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [policy_set_id][crate::model::PolicySet::policy_set_id].
    pub fn set_policy_set_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.policy_set_id = v.into();
        self
    }

    /// Sets the value of [description][crate::model::PolicySet::description].
    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.description = v.into();
        self
    }

    /// Sets the value of [policies][crate::model::PolicySet::policies].
    pub fn set_policies<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::Policy>,
    {
        use std::iter::Iterator;
        self.policies = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for PolicySet {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.securityposture.v1.PolicySet"
    }
}

/// Policy representation.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Policy {
    /// Required. ID of the Policy that is user generated, immutable and unique
    /// within the scope of a policy set.
    pub policy_id: std::string::String,

    /// Optional. Contains list of mapping for a Policy to a standard and control.
    pub compliance_standards: std::vec::Vec<crate::model::policy::ComplianceStandard>,

    /// Required. Constraint details.
    pub constraint: std::option::Option<crate::model::Constraint>,

    /// Optional. Description of the Policy.
    pub description: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Policy {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [policy_id][crate::model::Policy::policy_id].
    pub fn set_policy_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.policy_id = v.into();
        self
    }

    /// Sets the value of [compliance_standards][crate::model::Policy::compliance_standards].
    pub fn set_compliance_standards<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::policy::ComplianceStandard>,
    {
        use std::iter::Iterator;
        self.compliance_standards = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [constraint][crate::model::Policy::constraint].
    pub fn set_constraint<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Constraint>,
    {
        self.constraint = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [constraint][crate::model::Policy::constraint].
    pub fn set_or_clear_constraint<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Constraint>,
    {
        self.constraint = v.map(|x| x.into());
        self
    }

    /// Sets the value of [description][crate::model::Policy::description].
    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.description = v.into();
        self
    }
}

impl wkt::message::Message for Policy {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.securityposture.v1.Policy"
    }
}

/// Defines additional types related to [Policy].
pub mod policy {
    #[allow(unused_imports)]
    use super::*;

    /// Mapping for a Policy to standard and control.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct ComplianceStandard {
        /// Optional. The compliance standard that the Policy maps to, e.g.: CIS-2.0.
        pub standard: std::string::String,

        /// Optional. Control mapping provided by user for this Policy. e.g.: 1.5.
        pub control: std::string::String,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl ComplianceStandard {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [standard][crate::model::policy::ComplianceStandard::standard].
        pub fn set_standard<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
            self.standard = v.into();
            self
        }

        /// Sets the value of [control][crate::model::policy::ComplianceStandard::control].
        pub fn set_control<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
            self.control = v.into();
            self
        }
    }

    impl wkt::message::Message for ComplianceStandard {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.securityposture.v1.Policy.ComplianceStandard"
        }
    }
}

/// Representation of a Constraint.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Constraint {
    pub implementation: std::option::Option<crate::model::constraint::Implementation>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Constraint {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [implementation][crate::model::Constraint::implementation].
    ///
    /// Note that all the setters affecting `implementation` are mutually
    /// exclusive.
    pub fn set_implementation<
        T: std::convert::Into<std::option::Option<crate::model::constraint::Implementation>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.implementation = v.into();
        self
    }

    /// The value of [implementation][crate::model::Constraint::implementation]
    /// if it holds a `SecurityHealthAnalyticsModule`, `None` if the field is not set or
    /// holds a different branch.
    pub fn security_health_analytics_module(
        &self,
    ) -> std::option::Option<&std::boxed::Box<crate::model::SecurityHealthAnalyticsModule>> {
        #[allow(unreachable_patterns)]
        self.implementation.as_ref().and_then(|v| match v {
            crate::model::constraint::Implementation::SecurityHealthAnalyticsModule(v) => {
                std::option::Option::Some(v)
            }
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [implementation][crate::model::Constraint::implementation]
    /// to hold a `SecurityHealthAnalyticsModule`.
    ///
    /// Note that all the setters affecting `implementation` are
    /// mutually exclusive.
    pub fn set_security_health_analytics_module<
        T: std::convert::Into<std::boxed::Box<crate::model::SecurityHealthAnalyticsModule>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.implementation = std::option::Option::Some(
            crate::model::constraint::Implementation::SecurityHealthAnalyticsModule(v.into()),
        );
        self
    }

    /// The value of [implementation][crate::model::Constraint::implementation]
    /// if it holds a `SecurityHealthAnalyticsCustomModule`, `None` if the field is not set or
    /// holds a different branch.
    pub fn security_health_analytics_custom_module(
        &self,
    ) -> std::option::Option<&std::boxed::Box<crate::model::SecurityHealthAnalyticsCustomModule>>
    {
        #[allow(unreachable_patterns)]
        self.implementation.as_ref().and_then(|v| match v {
            crate::model::constraint::Implementation::SecurityHealthAnalyticsCustomModule(v) => {
                std::option::Option::Some(v)
            }
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [implementation][crate::model::Constraint::implementation]
    /// to hold a `SecurityHealthAnalyticsCustomModule`.
    ///
    /// Note that all the setters affecting `implementation` are
    /// mutually exclusive.
    pub fn set_security_health_analytics_custom_module<
        T: std::convert::Into<std::boxed::Box<crate::model::SecurityHealthAnalyticsCustomModule>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.implementation = std::option::Option::Some(
            crate::model::constraint::Implementation::SecurityHealthAnalyticsCustomModule(v.into()),
        );
        self
    }

    /// The value of [implementation][crate::model::Constraint::implementation]
    /// if it holds a `OrgPolicyConstraint`, `None` if the field is not set or
    /// holds a different branch.
    pub fn org_policy_constraint(
        &self,
    ) -> std::option::Option<&std::boxed::Box<crate::model::OrgPolicyConstraint>> {
        #[allow(unreachable_patterns)]
        self.implementation.as_ref().and_then(|v| match v {
            crate::model::constraint::Implementation::OrgPolicyConstraint(v) => {
                std::option::Option::Some(v)
            }
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [implementation][crate::model::Constraint::implementation]
    /// to hold a `OrgPolicyConstraint`.
    ///
    /// Note that all the setters affecting `implementation` are
    /// mutually exclusive.
    pub fn set_org_policy_constraint<
        T: std::convert::Into<std::boxed::Box<crate::model::OrgPolicyConstraint>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.implementation = std::option::Option::Some(
            crate::model::constraint::Implementation::OrgPolicyConstraint(v.into()),
        );
        self
    }

    /// The value of [implementation][crate::model::Constraint::implementation]
    /// if it holds a `OrgPolicyConstraintCustom`, `None` if the field is not set or
    /// holds a different branch.
    pub fn org_policy_constraint_custom(
        &self,
    ) -> std::option::Option<&std::boxed::Box<crate::model::OrgPolicyConstraintCustom>> {
        #[allow(unreachable_patterns)]
        self.implementation.as_ref().and_then(|v| match v {
            crate::model::constraint::Implementation::OrgPolicyConstraintCustom(v) => {
                std::option::Option::Some(v)
            }
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [implementation][crate::model::Constraint::implementation]
    /// to hold a `OrgPolicyConstraintCustom`.
    ///
    /// Note that all the setters affecting `implementation` are
    /// mutually exclusive.
    pub fn set_org_policy_constraint_custom<
        T: std::convert::Into<std::boxed::Box<crate::model::OrgPolicyConstraintCustom>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.implementation = std::option::Option::Some(
            crate::model::constraint::Implementation::OrgPolicyConstraintCustom(v.into()),
        );
        self
    }
}

impl wkt::message::Message for Constraint {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.securityposture.v1.Constraint"
    }
}

/// Defines additional types related to [Constraint].
pub mod constraint {
    #[allow(unused_imports)]
    use super::*;

    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum Implementation {
        /// Optional. SHA built-in detector.
        SecurityHealthAnalyticsModule(std::boxed::Box<crate::model::SecurityHealthAnalyticsModule>),
        /// Optional. SHA custom detector.
        SecurityHealthAnalyticsCustomModule(
            std::boxed::Box<crate::model::SecurityHealthAnalyticsCustomModule>,
        ),
        /// Optional. Org Policy builtin constraint.
        OrgPolicyConstraint(std::boxed::Box<crate::model::OrgPolicyConstraint>),
        /// Optional. Org Policy custom constraint.
        OrgPolicyConstraintCustom(std::boxed::Box<crate::model::OrgPolicyConstraintCustom>),
    }
}

/// Message for requesting list of Postures.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListPosturesRequest {
    /// Required. Parent value for ListPosturesRequest.
    pub parent: std::string::String,

    /// Requested page size. Server may return fewer items than requested.
    /// If unspecified, server will pick an appropriate default.
    pub page_size: i32,

    /// A token identifying a page of results the server should return.
    pub page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListPosturesRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::ListPosturesRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::ListPosturesRequest::page_size].
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model::ListPosturesRequest::page_token].
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }
}

impl wkt::message::Message for ListPosturesRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.securityposture.v1.ListPosturesRequest"
    }
}

/// Message for response to listing Postures.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListPosturesResponse {
    /// The list of Posture.
    pub postures: std::vec::Vec<crate::model::Posture>,

    /// A token identifying a page of results the server should return.
    pub next_page_token: std::string::String,

    /// Unreachable resources.
    pub unreachable: std::vec::Vec<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListPosturesResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [postures][crate::model::ListPosturesResponse::postures].
    pub fn set_postures<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::Posture>,
    {
        use std::iter::Iterator;
        self.postures = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::ListPosturesResponse::next_page_token].
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }

    /// Sets the value of [unreachable][crate::model::ListPosturesResponse::unreachable].
    pub fn set_unreachable<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.unreachable = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for ListPosturesResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.securityposture.v1.ListPosturesResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for ListPosturesResponse {
    type PageItem = crate::model::Posture;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.postures
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// Message for requesting list of Posture revisions.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListPostureRevisionsRequest {
    /// Required. Name value for ListPostureRevisionsRequest.
    pub name: std::string::String,

    /// Optional. Requested page size. Server may return fewer items than
    /// requested. If unspecified, server will pick 100 as default.
    pub page_size: i32,

    /// Optional. A token identifying a page of results the server should return.
    pub page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListPostureRevisionsRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::ListPostureRevisionsRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::ListPostureRevisionsRequest::page_size].
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model::ListPostureRevisionsRequest::page_token].
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }
}

impl wkt::message::Message for ListPostureRevisionsRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.securityposture.v1.ListPostureRevisionsRequest"
    }
}

/// Message for response to listing PostureRevisions.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListPostureRevisionsResponse {
    /// The list of Posture revisions.
    pub revisions: std::vec::Vec<crate::model::Posture>,

    /// A token identifying a page of results the server should return.
    pub next_page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListPostureRevisionsResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [revisions][crate::model::ListPostureRevisionsResponse::revisions].
    pub fn set_revisions<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::Posture>,
    {
        use std::iter::Iterator;
        self.revisions = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::ListPostureRevisionsResponse::next_page_token].
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }
}

impl wkt::message::Message for ListPostureRevisionsResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.securityposture.v1.ListPostureRevisionsResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for ListPostureRevisionsResponse {
    type PageItem = crate::model::Posture;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.revisions
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// Message for getting a Posture.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GetPostureRequest {
    /// Required. Name of the resource.
    pub name: std::string::String,

    /// Optional. Posture revision which needs to be retrieved.
    pub revision_id: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GetPostureRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::GetPostureRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [revision_id][crate::model::GetPostureRequest::revision_id].
    pub fn set_revision_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.revision_id = v.into();
        self
    }
}

impl wkt::message::Message for GetPostureRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.securityposture.v1.GetPostureRequest"
    }
}

/// Message for creating a Posture.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CreatePostureRequest {
    /// Required. Value for parent.
    pub parent: std::string::String,

    /// Required. User provided identifier. It should be unique in scope of an
    /// Organization and location.
    pub posture_id: std::string::String,

    /// Required. The resource being created.
    pub posture: std::option::Option<crate::model::Posture>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CreatePostureRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::CreatePostureRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [posture_id][crate::model::CreatePostureRequest::posture_id].
    pub fn set_posture_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.posture_id = v.into();
        self
    }

    /// Sets the value of [posture][crate::model::CreatePostureRequest::posture].
    pub fn set_posture<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Posture>,
    {
        self.posture = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [posture][crate::model::CreatePostureRequest::posture].
    pub fn set_or_clear_posture<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Posture>,
    {
        self.posture = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for CreatePostureRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.securityposture.v1.CreatePostureRequest"
    }
}

/// Message for updating a Posture.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct UpdatePostureRequest {
    /// Required. Field mask is used to specify the fields to be overwritten in the
    /// Posture resource by the update.
    /// The fields specified in the update_mask are relative to the resource, not
    /// the full request. A field will be overwritten if it is in the mask. If the
    /// user does not provide a mask then all fields will be overwritten.
    pub update_mask: std::option::Option<wkt::FieldMask>,

    /// Required. The resource being updated.
    pub posture: std::option::Option<crate::model::Posture>,

    /// Required. Posture revision which needs to be updated.
    pub revision_id: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl UpdatePostureRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [update_mask][crate::model::UpdatePostureRequest::update_mask].
    pub fn set_update_mask<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::FieldMask>,
    {
        self.update_mask = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [update_mask][crate::model::UpdatePostureRequest::update_mask].
    pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::FieldMask>,
    {
        self.update_mask = v.map(|x| x.into());
        self
    }

    /// Sets the value of [posture][crate::model::UpdatePostureRequest::posture].
    pub fn set_posture<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Posture>,
    {
        self.posture = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [posture][crate::model::UpdatePostureRequest::posture].
    pub fn set_or_clear_posture<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Posture>,
    {
        self.posture = v.map(|x| x.into());
        self
    }

    /// Sets the value of [revision_id][crate::model::UpdatePostureRequest::revision_id].
    pub fn set_revision_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.revision_id = v.into();
        self
    }
}

impl wkt::message::Message for UpdatePostureRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.securityposture.v1.UpdatePostureRequest"
    }
}

/// Message for deleting a Posture.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct DeletePostureRequest {
    /// Required. Name of the resource.
    pub name: std::string::String,

    /// Optional. Etag value of the Posture to be deleted.
    pub etag: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl DeletePostureRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::DeletePostureRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [etag][crate::model::DeletePostureRequest::etag].
    pub fn set_etag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.etag = v.into();
        self
    }
}

impl wkt::message::Message for DeletePostureRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.securityposture.v1.DeletePostureRequest"
    }
}

/// Message for extracting existing policies on a workload as a Posture.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ExtractPostureRequest {
    /// Required. The parent resource name. The format of this value is as follows:
    /// `organizations/{organization}/locations/{location}`
    pub parent: std::string::String,

    /// Required. User provided identifier. It should be unique in scope of an
    /// Organization and location.
    pub posture_id: std::string::String,

    /// Required. Workload from which the policies are to be extracted, it should
    /// belong to the same organization defined in parent. The format of this value
    /// varies depending on the scope of the request:
    ///
    /// - `folder/folderNumber`
    /// - `project/projectNumber`
    /// - `organization/organizationNumber`
    pub workload: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ExtractPostureRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::ExtractPostureRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [posture_id][crate::model::ExtractPostureRequest::posture_id].
    pub fn set_posture_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.posture_id = v.into();
        self
    }

    /// Sets the value of [workload][crate::model::ExtractPostureRequest::workload].
    pub fn set_workload<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.workload = v.into();
        self
    }
}

impl wkt::message::Message for ExtractPostureRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.securityposture.v1.ExtractPostureRequest"
    }
}

/// ========================== PostureDeployments ==========================
/// Message describing PostureDeployment resource.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct PostureDeployment {
    /// Required. The name of this PostureDeployment resource, in the format of
    /// organizations/{organization}/locations/{location_id}/postureDeployments/{postureDeployment}.
    pub name: std::string::String,

    /// Required. Target resource where the Posture will be deployed. Currently
    /// supported resources are of types: projects/projectNumber,
    /// folders/folderNumber, organizations/organizationNumber.
    pub target_resource: std::string::String,

    /// Output only. State of PostureDeployment resource.
    pub state: crate::model::posture_deployment::State,

    /// Required. Posture that needs to be deployed.
    /// Format:
    /// organizations/{org_id}/locations/{location_id}/postures/\<posture\>
    /// Example:
    /// organizations/99/locations/global/postures/les-miserables.
    pub posture_id: std::string::String,

    /// Required. Revision_id of the Posture that is to be deployed.
    pub posture_revision_id: std::string::String,

    /// Output only. The timestamp that the PostureDeployment was created.
    pub create_time: std::option::Option<wkt::Timestamp>,

    /// Output only. The timestamp that the PostureDeployment was updated.
    pub update_time: std::option::Option<wkt::Timestamp>,

    /// Optional. User provided description of the PostureDeployment.
    pub description: std::string::String,

    /// Optional. An opaque tag indicating the current version of the
    /// PostureDeployment, used for concurrency control. When the
    /// `PostureDeployment` is returned from either a `GetPostureDeployment` or a
    /// `ListPostureDeployments` request, this `etag` indicates the version of the
    /// current `PostureDeployment` to use when executing a read-modify-write loop.
    ///
    /// When the `PostureDeployment` is used in a `UpdatePostureDeployment` method,
    /// use the `etag` value that was returned from a `GetPostureDeployment`
    /// request as part of a read-modify-write loop for concurrency control. Not
    /// setting the `etag` in a `UpdatePostureDeployment` request will result in an
    /// unconditional write of the `PostureDeployment`.
    pub etag: std::string::String,

    /// Optional. User annotations. These attributes can only be set and used by
    /// the user, and not by Google Security Postures.
    /// .
    pub annotations: std::collections::HashMap<std::string::String, std::string::String>,

    /// Output only. Whether or not this Posture is in the process of being
    /// updated.
    pub reconciling: bool,

    /// Output only. This is a output only optional field which will be filled in
    /// case where PostureDeployment state is UPDATE_FAILED or CREATE_FAILED or
    /// DELETE_FAILED. It denotes the desired Posture.
    pub desired_posture_id: std::string::String,

    /// Output only. Output only optional field which provides revision_id of the
    /// desired_posture_id.
    pub desired_posture_revision_id: std::string::String,

    /// Output only. This is a output only optional field which will be filled in
    /// case where PostureDeployment enters a failure state like UPDATE_FAILED or
    /// CREATE_FAILED or DELETE_FAILED.
    pub failure_message: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl PostureDeployment {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::PostureDeployment::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [target_resource][crate::model::PostureDeployment::target_resource].
    pub fn set_target_resource<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.target_resource = v.into();
        self
    }

    /// Sets the value of [state][crate::model::PostureDeployment::state].
    pub fn set_state<T: std::convert::Into<crate::model::posture_deployment::State>>(
        mut self,
        v: T,
    ) -> Self {
        self.state = v.into();
        self
    }

    /// Sets the value of [posture_id][crate::model::PostureDeployment::posture_id].
    pub fn set_posture_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.posture_id = v.into();
        self
    }

    /// Sets the value of [posture_revision_id][crate::model::PostureDeployment::posture_revision_id].
    pub fn set_posture_revision_id<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.posture_revision_id = v.into();
        self
    }

    /// Sets the value of [create_time][crate::model::PostureDeployment::create_time].
    pub fn set_create_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [create_time][crate::model::PostureDeployment::create_time].
    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [update_time][crate::model::PostureDeployment::update_time].
    pub fn set_update_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.update_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [update_time][crate::model::PostureDeployment::update_time].
    pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.update_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [description][crate::model::PostureDeployment::description].
    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.description = v.into();
        self
    }

    /// Sets the value of [etag][crate::model::PostureDeployment::etag].
    pub fn set_etag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.etag = v.into();
        self
    }

    /// Sets the value of [annotations][crate::model::PostureDeployment::annotations].
    pub fn set_annotations<T, K, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = (K, V)>,
        K: std::convert::Into<std::string::String>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.annotations = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
        self
    }

    /// Sets the value of [reconciling][crate::model::PostureDeployment::reconciling].
    pub fn set_reconciling<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.reconciling = v.into();
        self
    }

    /// Sets the value of [desired_posture_id][crate::model::PostureDeployment::desired_posture_id].
    pub fn set_desired_posture_id<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.desired_posture_id = v.into();
        self
    }

    /// Sets the value of [desired_posture_revision_id][crate::model::PostureDeployment::desired_posture_revision_id].
    pub fn set_desired_posture_revision_id<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.desired_posture_revision_id = v.into();
        self
    }

    /// Sets the value of [failure_message][crate::model::PostureDeployment::failure_message].
    pub fn set_failure_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.failure_message = v.into();
        self
    }
}

impl wkt::message::Message for PostureDeployment {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.securityposture.v1.PostureDeployment"
    }
}

/// Defines additional types related to [PostureDeployment].
pub mod posture_deployment {
    #[allow(unused_imports)]
    use super::*;

    /// State of a PostureDeployment.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum State {
        /// Unspecified operation state.
        Unspecified,
        /// The PostureDeployment is being created.
        Creating,
        /// The PostureDeployment is being deleted.
        Deleting,
        /// The PostureDeployment state is being updated.
        Updating,
        /// The PostureDeployment state is active and in use.
        Active,
        /// The PostureDeployment creation failed.
        CreateFailed,
        /// The PostureDeployment update failed.
        UpdateFailed,
        /// The PostureDeployment deletion failed.
        DeleteFailed,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [State::value] or
        /// [State::name].
        UnknownValue(state::UnknownValue),
    }

    #[doc(hidden)]
    pub mod state {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl State {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::Creating => std::option::Option::Some(1),
                Self::Deleting => std::option::Option::Some(2),
                Self::Updating => std::option::Option::Some(3),
                Self::Active => std::option::Option::Some(4),
                Self::CreateFailed => std::option::Option::Some(5),
                Self::UpdateFailed => std::option::Option::Some(6),
                Self::DeleteFailed => std::option::Option::Some(7),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
                Self::Creating => std::option::Option::Some("CREATING"),
                Self::Deleting => std::option::Option::Some("DELETING"),
                Self::Updating => std::option::Option::Some("UPDATING"),
                Self::Active => std::option::Option::Some("ACTIVE"),
                Self::CreateFailed => std::option::Option::Some("CREATE_FAILED"),
                Self::UpdateFailed => std::option::Option::Some("UPDATE_FAILED"),
                Self::DeleteFailed => std::option::Option::Some("DELETE_FAILED"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for State {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for State {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for State {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::Creating,
                2 => Self::Deleting,
                3 => Self::Updating,
                4 => Self::Active,
                5 => Self::CreateFailed,
                6 => Self::UpdateFailed,
                7 => Self::DeleteFailed,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for State {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "STATE_UNSPECIFIED" => Self::Unspecified,
                "CREATING" => Self::Creating,
                "DELETING" => Self::Deleting,
                "UPDATING" => Self::Updating,
                "ACTIVE" => Self::Active,
                "CREATE_FAILED" => Self::CreateFailed,
                "UPDATE_FAILED" => Self::UpdateFailed,
                "DELETE_FAILED" => Self::DeleteFailed,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for State {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::Creating => serializer.serialize_i32(1),
                Self::Deleting => serializer.serialize_i32(2),
                Self::Updating => serializer.serialize_i32(3),
                Self::Active => serializer.serialize_i32(4),
                Self::CreateFailed => serializer.serialize_i32(5),
                Self::UpdateFailed => serializer.serialize_i32(6),
                Self::DeleteFailed => serializer.serialize_i32(7),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for State {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
                ".google.cloud.securityposture.v1.PostureDeployment.State",
            ))
        }
    }
}

/// Message for requesting list of PostureDeployments.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListPostureDeploymentsRequest {
    /// Required. Parent value for ListPostureDeploymentsRequest.
    pub parent: std::string::String,

    /// Optional. Requested page size. Server may return fewer items than
    /// requested. If unspecified, server will pick an appropriate default.
    pub page_size: i32,

    /// Optional. A token identifying a page of results the server should return.
    pub page_token: std::string::String,

    /// Optional. Filter to be applied on the resource, defined by EBNF grammar
    /// <https://google.aip.dev/assets/misc/ebnf-filtering.txt>.
    pub filter: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListPostureDeploymentsRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::ListPostureDeploymentsRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::ListPostureDeploymentsRequest::page_size].
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model::ListPostureDeploymentsRequest::page_token].
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }

    /// Sets the value of [filter][crate::model::ListPostureDeploymentsRequest::filter].
    pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.filter = v.into();
        self
    }
}

impl wkt::message::Message for ListPostureDeploymentsRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.securityposture.v1.ListPostureDeploymentsRequest"
    }
}

/// Message for response to listing PostureDeployments.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListPostureDeploymentsResponse {
    /// The list of PostureDeployment.
    pub posture_deployments: std::vec::Vec<crate::model::PostureDeployment>,

    /// A token identifying a page of results the server should return.
    pub next_page_token: std::string::String,

    /// Locations that could not be reached.
    pub unreachable: std::vec::Vec<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListPostureDeploymentsResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [posture_deployments][crate::model::ListPostureDeploymentsResponse::posture_deployments].
    pub fn set_posture_deployments<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::PostureDeployment>,
    {
        use std::iter::Iterator;
        self.posture_deployments = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::ListPostureDeploymentsResponse::next_page_token].
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }

    /// Sets the value of [unreachable][crate::model::ListPostureDeploymentsResponse::unreachable].
    pub fn set_unreachable<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.unreachable = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for ListPostureDeploymentsResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.securityposture.v1.ListPostureDeploymentsResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for ListPostureDeploymentsResponse {
    type PageItem = crate::model::PostureDeployment;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.posture_deployments
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// Message for getting a PostureDeployment.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GetPostureDeploymentRequest {
    /// Required. Name of the resource.
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GetPostureDeploymentRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::GetPostureDeploymentRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for GetPostureDeploymentRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.securityposture.v1.GetPostureDeploymentRequest"
    }
}

/// Message for creating a PostureDeployment.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CreatePostureDeploymentRequest {
    /// Required. Value for parent.
    /// Format: organizations/{org_id}/locations/{location}
    pub parent: std::string::String,

    /// Required. User provided identifier. It should be unique in scope of an
    /// Organization and location.
    pub posture_deployment_id: std::string::String,

    /// Required. The resource being created.
    pub posture_deployment: std::option::Option<crate::model::PostureDeployment>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CreatePostureDeploymentRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::CreatePostureDeploymentRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [posture_deployment_id][crate::model::CreatePostureDeploymentRequest::posture_deployment_id].
    pub fn set_posture_deployment_id<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.posture_deployment_id = v.into();
        self
    }

    /// Sets the value of [posture_deployment][crate::model::CreatePostureDeploymentRequest::posture_deployment].
    pub fn set_posture_deployment<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::PostureDeployment>,
    {
        self.posture_deployment = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [posture_deployment][crate::model::CreatePostureDeploymentRequest::posture_deployment].
    pub fn set_or_clear_posture_deployment<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::PostureDeployment>,
    {
        self.posture_deployment = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for CreatePostureDeploymentRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.securityposture.v1.CreatePostureDeploymentRequest"
    }
}

/// Message for updating a PostureDeployment.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct UpdatePostureDeploymentRequest {
    /// Required. Field mask is used to specify the fields to be overwritten in the
    /// PostureDeployment resource by the update.
    /// The fields specified in the update_mask are relative to the resource, not
    /// the full request. A field will be overwritten if it is in the mask. If the
    /// user does not provide a mask then all fields will be overwritten.
    pub update_mask: std::option::Option<wkt::FieldMask>,

    /// Required. The resource being updated.
    pub posture_deployment: std::option::Option<crate::model::PostureDeployment>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl UpdatePostureDeploymentRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [update_mask][crate::model::UpdatePostureDeploymentRequest::update_mask].
    pub fn set_update_mask<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::FieldMask>,
    {
        self.update_mask = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [update_mask][crate::model::UpdatePostureDeploymentRequest::update_mask].
    pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::FieldMask>,
    {
        self.update_mask = v.map(|x| x.into());
        self
    }

    /// Sets the value of [posture_deployment][crate::model::UpdatePostureDeploymentRequest::posture_deployment].
    pub fn set_posture_deployment<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::PostureDeployment>,
    {
        self.posture_deployment = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [posture_deployment][crate::model::UpdatePostureDeploymentRequest::posture_deployment].
    pub fn set_or_clear_posture_deployment<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::PostureDeployment>,
    {
        self.posture_deployment = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for UpdatePostureDeploymentRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.securityposture.v1.UpdatePostureDeploymentRequest"
    }
}

/// Message for deleting a PostureDeployment.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct DeletePostureDeploymentRequest {
    /// Required. Name of the resource.
    pub name: std::string::String,

    /// Optional. Etag value of the PostureDeployment to be deleted.
    pub etag: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl DeletePostureDeploymentRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::DeletePostureDeploymentRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [etag][crate::model::DeletePostureDeploymentRequest::etag].
    pub fn set_etag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.etag = v.into();
        self
    }
}

impl wkt::message::Message for DeletePostureDeploymentRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.securityposture.v1.DeletePostureDeploymentRequest"
    }
}

/// PostureTemplates
/// Message describing PostureTemplate object.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct PostureTemplate {
    /// Output only. Identifier. The name of the Posture template will be of the
    /// format
    /// organizations/{organization}/locations/{location}/postureTemplates/{postureTemplate}
    pub name: std::string::String,

    /// Output only. The revision_id of a PostureTemplate.
    pub revision_id: std::string::String,

    /// Output only. Description of the Posture template.
    pub description: std::string::String,

    /// Output only. State of PostureTemplate resource.
    pub state: crate::model::posture_template::State,

    /// Output only. Policy_sets to be used by the user.
    pub policy_sets: std::vec::Vec<crate::model::PolicySet>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl PostureTemplate {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::PostureTemplate::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [revision_id][crate::model::PostureTemplate::revision_id].
    pub fn set_revision_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.revision_id = v.into();
        self
    }

    /// Sets the value of [description][crate::model::PostureTemplate::description].
    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.description = v.into();
        self
    }

    /// Sets the value of [state][crate::model::PostureTemplate::state].
    pub fn set_state<T: std::convert::Into<crate::model::posture_template::State>>(
        mut self,
        v: T,
    ) -> Self {
        self.state = v.into();
        self
    }

    /// Sets the value of [policy_sets][crate::model::PostureTemplate::policy_sets].
    pub fn set_policy_sets<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::PolicySet>,
    {
        use std::iter::Iterator;
        self.policy_sets = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for PostureTemplate {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.securityposture.v1.PostureTemplate"
    }
}

/// Defines additional types related to [PostureTemplate].
pub mod posture_template {
    #[allow(unused_imports)]
    use super::*;

    /// State of a PostureTemplate
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum State {
        /// Unspecified state
        Unspecified,
        /// If the Posture template is adhering to the latest controls and standards.
        Active,
        /// If the Posture template controls and standards are outdated and not
        /// recommended for use.
        Deprecated,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [State::value] or
        /// [State::name].
        UnknownValue(state::UnknownValue),
    }

    #[doc(hidden)]
    pub mod state {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl State {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::Active => std::option::Option::Some(1),
                Self::Deprecated => std::option::Option::Some(2),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
                Self::Active => std::option::Option::Some("ACTIVE"),
                Self::Deprecated => std::option::Option::Some("DEPRECATED"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for State {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for State {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for State {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::Active,
                2 => Self::Deprecated,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for State {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "STATE_UNSPECIFIED" => Self::Unspecified,
                "ACTIVE" => Self::Active,
                "DEPRECATED" => Self::Deprecated,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for State {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::Active => serializer.serialize_i32(1),
                Self::Deprecated => serializer.serialize_i32(2),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for State {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
                ".google.cloud.securityposture.v1.PostureTemplate.State",
            ))
        }
    }
}

/// Message for requesting list of Posture Templates.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListPostureTemplatesRequest {
    /// Required. Parent value for ListPostureTemplatesRequest.
    pub parent: std::string::String,

    /// Optional. Requested page size. Server may return fewer items than
    /// requested. If unspecified, server will pick an appropriate default.
    pub page_size: i32,

    /// Optional. A token identifying a page of results the server should return.
    pub page_token: std::string::String,

    /// Optional. Filter to be applied on the resource, defined by EBNF grammar
    /// <https://google.aip.dev/assets/misc/ebnf-filtering.txt>.
    pub filter: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListPostureTemplatesRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::ListPostureTemplatesRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::ListPostureTemplatesRequest::page_size].
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model::ListPostureTemplatesRequest::page_token].
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }

    /// Sets the value of [filter][crate::model::ListPostureTemplatesRequest::filter].
    pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.filter = v.into();
        self
    }
}

impl wkt::message::Message for ListPostureTemplatesRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.securityposture.v1.ListPostureTemplatesRequest"
    }
}

/// Message for response to listing PostureTemplates.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListPostureTemplatesResponse {
    /// The list of PostureTemplate.
    pub posture_templates: std::vec::Vec<crate::model::PostureTemplate>,

    /// A token identifying a page of results the server should return.
    pub next_page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListPostureTemplatesResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [posture_templates][crate::model::ListPostureTemplatesResponse::posture_templates].
    pub fn set_posture_templates<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::PostureTemplate>,
    {
        use std::iter::Iterator;
        self.posture_templates = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::ListPostureTemplatesResponse::next_page_token].
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }
}

impl wkt::message::Message for ListPostureTemplatesResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.securityposture.v1.ListPostureTemplatesResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for ListPostureTemplatesResponse {
    type PageItem = crate::model::PostureTemplate;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.posture_templates
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// Message for getting a Posture Template.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GetPostureTemplateRequest {
    /// Required. Name of the resource.
    pub name: std::string::String,

    /// Optional. Specific revision_id of a Posture Template.
    /// PostureTemplate revision_id which needs to be retrieved.
    pub revision_id: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GetPostureTemplateRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::GetPostureTemplateRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [revision_id][crate::model::GetPostureTemplateRequest::revision_id].
    pub fn set_revision_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.revision_id = v.into();
        self
    }
}

impl wkt::message::Message for GetPostureTemplateRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.securityposture.v1.GetPostureTemplateRequest"
    }
}

/// Message for Security Health Analytics built-in detector.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct SecurityHealthAnalyticsModule {
    /// Required. The name of the module eg: BIGQUERY_TABLE_CMEK_DISABLED.
    pub module_name: std::string::String,

    /// The state of enablement for the module at its level of the resource
    /// hierarchy.
    pub module_enablement_state: crate::model::EnablementState,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl SecurityHealthAnalyticsModule {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [module_name][crate::model::SecurityHealthAnalyticsModule::module_name].
    pub fn set_module_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.module_name = v.into();
        self
    }

    /// Sets the value of [module_enablement_state][crate::model::SecurityHealthAnalyticsModule::module_enablement_state].
    pub fn set_module_enablement_state<T: std::convert::Into<crate::model::EnablementState>>(
        mut self,
        v: T,
    ) -> Self {
        self.module_enablement_state = v.into();
        self
    }
}

impl wkt::message::Message for SecurityHealthAnalyticsModule {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.securityposture.v1.SecurityHealthAnalyticsModule"
    }
}

/// Message for SHA Custom Module
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct SecurityHealthAnalyticsCustomModule {
    /// Output only. Immutable. The id of the custom module.
    /// The id is server-generated and is not user settable.
    /// It will be a numeric id containing 1-20 digits.
    pub id: std::string::String,

    /// Optional. The display name of the Security Health Analytics custom module.
    /// This display name becomes the finding category for all findings that are
    /// returned by this custom module. The display name must be between 1 and
    /// 128 characters, start with a lowercase letter, and contain alphanumeric
    /// characters or underscores only.
    pub display_name: std::string::String,

    /// Required. custom module details
    pub config: std::option::Option<crate::model::CustomConfig>,

    /// The state of enablement for the module at its level of the resource
    /// hierarchy.
    pub module_enablement_state: crate::model::EnablementState,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl SecurityHealthAnalyticsCustomModule {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [id][crate::model::SecurityHealthAnalyticsCustomModule::id].
    pub fn set_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.id = v.into();
        self
    }

    /// Sets the value of [display_name][crate::model::SecurityHealthAnalyticsCustomModule::display_name].
    pub fn set_display_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.display_name = v.into();
        self
    }

    /// Sets the value of [config][crate::model::SecurityHealthAnalyticsCustomModule::config].
    pub fn set_config<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::CustomConfig>,
    {
        self.config = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [config][crate::model::SecurityHealthAnalyticsCustomModule::config].
    pub fn set_or_clear_config<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::CustomConfig>,
    {
        self.config = v.map(|x| x.into());
        self
    }

    /// Sets the value of [module_enablement_state][crate::model::SecurityHealthAnalyticsCustomModule::module_enablement_state].
    pub fn set_module_enablement_state<T: std::convert::Into<crate::model::EnablementState>>(
        mut self,
        v: T,
    ) -> Self {
        self.module_enablement_state = v.into();
        self
    }
}

impl wkt::message::Message for SecurityHealthAnalyticsCustomModule {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.securityposture.v1.SecurityHealthAnalyticsCustomModule"
    }
}

/// Defines the properties in a custom module configuration for Security
/// Health Analytics. Use the custom module configuration to create custom
/// detectors that generate custom findings for resources that you specify.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CustomConfig {
    /// Required. The CEL expression to evaluate to produce findings. When the
    /// expression evaluates to true against a resource, a finding is generated.
    pub predicate: std::option::Option<gtype::model::Expr>,

    /// Optional. Custom output properties.
    pub custom_output: std::option::Option<crate::model::custom_config::CustomOutputSpec>,

    /// Required. The resource types that the custom module operates on. Each
    /// custom module can specify up to 5 resource types.
    pub resource_selector: std::option::Option<crate::model::custom_config::ResourceSelector>,

    /// Required. The severity to assign to findings generated by the module.
    pub severity: crate::model::custom_config::Severity,

    /// Optional. Text that describes the vulnerability or misconfiguration that
    /// the custom module detects. This explanation is returned with each finding
    /// instance to help investigators understand the detected issue. The text must
    /// be enclosed in quotation marks.
    pub description: std::string::String,

    /// Optional. An explanation of the recommended steps that security teams can
    /// take to resolve the detected issue. This explanation is returned with each
    /// finding generated by this module in the `nextSteps` property of the finding
    /// JSON.
    pub recommendation: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CustomConfig {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [predicate][crate::model::CustomConfig::predicate].
    pub fn set_predicate<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<gtype::model::Expr>,
    {
        self.predicate = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [predicate][crate::model::CustomConfig::predicate].
    pub fn set_or_clear_predicate<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<gtype::model::Expr>,
    {
        self.predicate = v.map(|x| x.into());
        self
    }

    /// Sets the value of [custom_output][crate::model::CustomConfig::custom_output].
    pub fn set_custom_output<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::custom_config::CustomOutputSpec>,
    {
        self.custom_output = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [custom_output][crate::model::CustomConfig::custom_output].
    pub fn set_or_clear_custom_output<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::custom_config::CustomOutputSpec>,
    {
        self.custom_output = v.map(|x| x.into());
        self
    }

    /// Sets the value of [resource_selector][crate::model::CustomConfig::resource_selector].
    pub fn set_resource_selector<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::custom_config::ResourceSelector>,
    {
        self.resource_selector = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [resource_selector][crate::model::CustomConfig::resource_selector].
    pub fn set_or_clear_resource_selector<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::custom_config::ResourceSelector>,
    {
        self.resource_selector = v.map(|x| x.into());
        self
    }

    /// Sets the value of [severity][crate::model::CustomConfig::severity].
    pub fn set_severity<T: std::convert::Into<crate::model::custom_config::Severity>>(
        mut self,
        v: T,
    ) -> Self {
        self.severity = v.into();
        self
    }

    /// Sets the value of [description][crate::model::CustomConfig::description].
    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.description = v.into();
        self
    }

    /// Sets the value of [recommendation][crate::model::CustomConfig::recommendation].
    pub fn set_recommendation<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.recommendation = v.into();
        self
    }
}

impl wkt::message::Message for CustomConfig {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.securityposture.v1.CustomConfig"
    }
}

/// Defines additional types related to [CustomConfig].
pub mod custom_config {
    #[allow(unused_imports)]
    use super::*;

    /// A set of optional name-value pairs that define custom source properties to
    /// return with each finding that is generated by the custom module. The custom
    /// source properties that are defined here are included in the finding JSON
    /// under `sourceProperties`.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct CustomOutputSpec {
        /// Optional. A list of custom output properties to add to the finding.
        pub properties: std::vec::Vec<crate::model::custom_config::custom_output_spec::Property>,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl CustomOutputSpec {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [properties][crate::model::custom_config::CustomOutputSpec::properties].
        pub fn set_properties<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<crate::model::custom_config::custom_output_spec::Property>,
        {
            use std::iter::Iterator;
            self.properties = v.into_iter().map(|i| i.into()).collect();
            self
        }
    }

    impl wkt::message::Message for CustomOutputSpec {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.securityposture.v1.CustomConfig.CustomOutputSpec"
        }
    }

    /// Defines additional types related to [CustomOutputSpec].
    pub mod custom_output_spec {
        #[allow(unused_imports)]
        use super::*;

        /// An individual name-value pair that defines a custom source property.
        #[derive(Clone, Default, PartialEq)]
        #[non_exhaustive]
        pub struct Property {
            /// Required. Name of the property for the custom output.
            pub name: std::string::String,

            /// Optional. The CEL expression for the custom output. A resource property
            /// can be specified to return the value of the property or a text string
            /// enclosed in quotation marks.
            pub value_expression: std::option::Option<gtype::model::Expr>,

            pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
        }

        impl Property {
            pub fn new() -> Self {
                std::default::Default::default()
            }

            /// Sets the value of [name][crate::model::custom_config::custom_output_spec::Property::name].
            pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
                self.name = v.into();
                self
            }

            /// Sets the value of [value_expression][crate::model::custom_config::custom_output_spec::Property::value_expression].
            pub fn set_value_expression<T>(mut self, v: T) -> Self
            where
                T: std::convert::Into<gtype::model::Expr>,
            {
                self.value_expression = std::option::Option::Some(v.into());
                self
            }

            /// Sets or clears the value of [value_expression][crate::model::custom_config::custom_output_spec::Property::value_expression].
            pub fn set_or_clear_value_expression<T>(mut self, v: std::option::Option<T>) -> Self
            where
                T: std::convert::Into<gtype::model::Expr>,
            {
                self.value_expression = v.map(|x| x.into());
                self
            }
        }

        impl wkt::message::Message for Property {
            fn typename() -> &'static str {
                "type.googleapis.com/google.cloud.securityposture.v1.CustomConfig.CustomOutputSpec.Property"
            }
        }
    }

    /// Resource for selecting resource type.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct ResourceSelector {
        /// Required. The resource types to run the detector on.
        pub resource_types: std::vec::Vec<std::string::String>,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl ResourceSelector {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [resource_types][crate::model::custom_config::ResourceSelector::resource_types].
        pub fn set_resource_types<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<std::string::String>,
        {
            use std::iter::Iterator;
            self.resource_types = v.into_iter().map(|i| i.into()).collect();
            self
        }
    }

    impl wkt::message::Message for ResourceSelector {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.securityposture.v1.CustomConfig.ResourceSelector"
        }
    }

    /// Defines the valid value options for the severity of a finding.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum Severity {
        /// Unspecified severity.
        Unspecified,
        /// Critical severity.
        Critical,
        /// High severity.
        High,
        /// Medium severity.
        Medium,
        /// Low severity.
        Low,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [Severity::value] or
        /// [Severity::name].
        UnknownValue(severity::UnknownValue),
    }

    #[doc(hidden)]
    pub mod severity {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl Severity {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::Critical => std::option::Option::Some(1),
                Self::High => std::option::Option::Some(2),
                Self::Medium => std::option::Option::Some(3),
                Self::Low => std::option::Option::Some(4),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("SEVERITY_UNSPECIFIED"),
                Self::Critical => std::option::Option::Some("CRITICAL"),
                Self::High => std::option::Option::Some("HIGH"),
                Self::Medium => std::option::Option::Some("MEDIUM"),
                Self::Low => std::option::Option::Some("LOW"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for Severity {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for Severity {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for Severity {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::Critical,
                2 => Self::High,
                3 => Self::Medium,
                4 => Self::Low,
                _ => Self::UnknownValue(severity::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for Severity {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "SEVERITY_UNSPECIFIED" => Self::Unspecified,
                "CRITICAL" => Self::Critical,
                "HIGH" => Self::High,
                "MEDIUM" => Self::Medium,
                "LOW" => Self::Low,
                _ => Self::UnknownValue(severity::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for Severity {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::Critical => serializer.serialize_i32(1),
                Self::High => serializer.serialize_i32(2),
                Self::Medium => serializer.serialize_i32(3),
                Self::Low => serializer.serialize_i32(4),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for Severity {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<Severity>::new(
                ".google.cloud.securityposture.v1.CustomConfig.Severity",
            ))
        }
    }
}

/// Possible enablement states of a service or module.
///
/// # Working with unknown values
///
/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
/// additional enum variants at any time. Adding new variants is not considered
/// a breaking change. Applications should write their code in anticipation of:
///
/// - New values appearing in future releases of the client library, **and**
/// - New values received dynamically, without application changes.
///
/// Please consult the [Working with enums] section in the user guide for some
/// guidelines.
///
/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum EnablementState {
    /// Default value. This value is unused.
    Unspecified,
    /// State is enabled.
    Enabled,
    /// State is disabled.
    Disabled,
    /// If set, the enum was initialized with an unknown value.
    ///
    /// Applications can examine the value using [EnablementState::value] or
    /// [EnablementState::name].
    UnknownValue(enablement_state::UnknownValue),
}

#[doc(hidden)]
pub mod enablement_state {
    #[allow(unused_imports)]
    use super::*;
    #[derive(Clone, Debug, PartialEq)]
    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}

impl EnablementState {
    /// Gets the enum value.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the string representation of enums.
    pub fn value(&self) -> std::option::Option<i32> {
        match self {
            Self::Unspecified => std::option::Option::Some(0),
            Self::Enabled => std::option::Option::Some(1),
            Self::Disabled => std::option::Option::Some(2),
            Self::UnknownValue(u) => u.0.value(),
        }
    }

    /// Gets the enum value as a string.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the integer representation of enums.
    pub fn name(&self) -> std::option::Option<&str> {
        match self {
            Self::Unspecified => std::option::Option::Some("ENABLEMENT_STATE_UNSPECIFIED"),
            Self::Enabled => std::option::Option::Some("ENABLED"),
            Self::Disabled => std::option::Option::Some("DISABLED"),
            Self::UnknownValue(u) => u.0.name(),
        }
    }
}

impl std::default::Default for EnablementState {
    fn default() -> Self {
        use std::convert::From;
        Self::from(0)
    }
}

impl std::fmt::Display for EnablementState {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
        wkt::internal::display_enum(f, self.name(), self.value())
    }
}

impl std::convert::From<i32> for EnablementState {
    fn from(value: i32) -> Self {
        match value {
            0 => Self::Unspecified,
            1 => Self::Enabled,
            2 => Self::Disabled,
            _ => Self::UnknownValue(enablement_state::UnknownValue(
                wkt::internal::UnknownEnumValue::Integer(value),
            )),
        }
    }
}

impl std::convert::From<&str> for EnablementState {
    fn from(value: &str) -> Self {
        use std::string::ToString;
        match value {
            "ENABLEMENT_STATE_UNSPECIFIED" => Self::Unspecified,
            "ENABLED" => Self::Enabled,
            "DISABLED" => Self::Disabled,
            _ => Self::UnknownValue(enablement_state::UnknownValue(
                wkt::internal::UnknownEnumValue::String(value.to_string()),
            )),
        }
    }
}

impl serde::ser::Serialize for EnablementState {
    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        match self {
            Self::Unspecified => serializer.serialize_i32(0),
            Self::Enabled => serializer.serialize_i32(1),
            Self::Disabled => serializer.serialize_i32(2),
            Self::UnknownValue(u) => u.0.serialize(serializer),
        }
    }
}

impl<'de> serde::de::Deserialize<'de> for EnablementState {
    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        deserializer.deserialize_any(wkt::internal::EnumVisitor::<EnablementState>::new(
            ".google.cloud.securityposture.v1.EnablementState",
        ))
    }
}
